package cn.mdmbct.spring.starter.douyin.common.properties.dy;

import cn.mdmbct.douyin.common.enums.HttpClientType;
import lombok.Data;
import lombok.Getter;

import java.io.Serializable;

/**
 * http配置
 *
 * @author mdmbct  mdmbct@outlook.com
 * @date 2021/3/19 20:27
 * @modified mdmbct
 * @since 1.0
 */
@Getter
public class HttpProperties implements Serializable {

    public static final String PREFIX = "dy.open.http";

    private static final long serialVersionUID = -8791436766847279398L;

    /**
     * 发送http请求的实现方式 默认{@link HttpClientType#OK_HTTP}
     */
    private HttpClientType type = HttpClientType.OK_HTTP;

    /**
     * 请求失败重试次数 默认3次 最多10次 <P>
     * 重试次数小于等于0 被设置为默认3次重试 <p>
     * 大于10 被设置成10次
     */
    private int maxRetry = 3;

    /**
     * 从发起请求到响应的时间间隔 默认5 * 60 * 1000ms （5min）
     */
    private long responseTimeout = 300_000;

    /**
     * 连接时间 默认5 * 1000ms
     */
    private long connectTimeout = 5_000;

    public void setType(HttpClientType type) {
        this.type = type;
    }

    public void setMaxRetry(int maxRetry) {
        this.maxRetry = maxRetry;
    }

    public void setResponseTimeout(long responseTimeout) {
        this.responseTimeout = responseTimeout;
    }

    public void setConnectTimeout(long connectTimeout) {
        this.connectTimeout = connectTimeout;
    }
}
